package com.ppsea;

import org.eclipse.swt.widgets.Shell;

public class SWTUtils
{
  public static void centerWnd(Shell shell)
  {
    int width = shell.getMonitor().getClientArea().width;
    int height = shell.getMonitor().getClientArea().height;
    int x = shell.getSize().x;
    int y = shell.getSize().y;
    if (x > width) {
      shell.getSize().x = width;
    }
    if (y > height) {
      shell.getSize().y = height;
    }
    shell.setLocation((width - x) / 2, (height - y) / 2);
  }
}